package com.imooc.controller;


import com.imooc.api.intercept.JWTCurrentUserInterceptor;
import com.imooc.pojo.Stu;
import com.imooc.pojo.Users;
import com.imooc.service.StuService;
import io.lettuce.core.output.ListOfGenericMapsOutput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("u")
public class HelloController {

    @Autowired
    private StuService stuService;

    @GetMapping("test")
    public Object test(){
        Stu stu = new Stu();
        stu.setId("1003");
        stu.setAge(19);
        stu.setName("yangtao2");
        stuService.save(stu);
        return "ok";
    }

    @GetMapping("test2")
    public Object test2(){
        return "ok111111111";
    }

    @GetMapping("hello")
    public Object hello(){
        Users users = JWTCurrentUserInterceptor.currentUser.get();
        System.out.println("hello中通过拦截器获得用户数据："+users);
        return "ok111111111";
    }


}
